package com.sdses.weather.api;

import com.sdses.weather.model.req.WeatherReq;
import com.sdses.weather.service.WeatherQueryCommonService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 天气查询控制器
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/weather")
@RequiredArgsConstructor
public class WeatherCommonApi {


    private final WeatherQueryCommonService weatherQueryCommonService;

    /**
     * 天气实况接口
     * 对应返回的类 WeatherConditionInfo
     */
    @GetMapping("/condition")
    public Object condition(@ModelAttribute WeatherReq weatherReq) {
        return weatherQueryCommonService.execute();
    }

    /**
     * 24小时天气预报接口
     *
     * HourlyForecastInfo
     */
    @GetMapping("/forecast24hours")
    public Object forecast24hours(@ModelAttribute WeatherReq weatherReq) {
        return weatherQueryCommonService.execute();
    }

    /**
     * 15天天气预报接口
     *
     * DailyForecastInfo
     */
    @GetMapping("/forecast15days")
    public Object getWeatherForecast15days(@ModelAttribute WeatherReq weatherReq) {
        return weatherQueryCommonService.execute();
    }

    /**
     * 天气预警接口
     *
     * WarningInfo
     */
    @GetMapping("/alert")
    public Object getWeatherAlert(@ModelAttribute WeatherReq weatherReq) {
        return weatherQueryCommonService.execute();
    }

    /**
     * 短时60分钟级别
     * 墨迹天气只支持经纬度
     *
     * MinutelyForecastInfo
     */
    @GetMapping("/forecast60minutes")
    public Object getForecast60minutes(@ModelAttribute WeatherReq weatherReq) {
        return weatherQueryCommonService.execute();
    }

} 